import {ref,watch} from 'vue' const useAdd = ({num1,num2})=>{ const sum = ref(0)
watch([num1,num2],([num1,num2])=>{ _sumFn(num1,num2) }) const _sumFn =
(num1,num2)=>{ sum.value = num1+num2 } return { _sumFn,sum } } // 使用

<div>num1+num2 : {{sum}}</div>

const { sum, _sumFn } = useAdd({ num1, num2 }) _sumFn(num1.value, num2.value)
